class CreateCurrencies < ActiveRecord::Migration
  def self.up
    create_table :currencies do |t|
      t.string :code, :limit => 3, :null => false
      t.string :name
      t.string :format
    end

    add_index :currencies, :code, :unique => true

    Currency.create([
      {:code => 'EUR', :format => "%.2f"},
      {:code => 'USD', :format => "%.2f"},
      {:code => 'BLR', :format => "%.2f"},
      {:code => 'RUB', :format => "%.2f"},
    ])
  end

  def self.down
    drop_table :currencies
  end
end
